package com.example.pertecttime.activity.main;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.example.pertecttime.R;
import com.example.pertecttime.adapter.TabFragmentPagerAdapter;
import com.example.pertecttime.base.BaseActicvity;
import com.example.pertecttime.fragent.friend.FriendFragment;
import com.example.pertecttime.fragent.group.GroupFragment;
import com.example.pertecttime.fragent.timeline.TimelineFragment;

import java.util.ArrayList;

/**
 * Created by 半生瓜 on 2017/7/20.
 */

public class mainActivity extends BaseActicvity<mainPresenter, mainModle> implements mainContract.view {

    private Toolbar main_toolbar;
    private TabLayout main_tablayout;
    private ViewPager main_viewpager;
    private Fragment friendFragment = new FriendFragment();
    private Fragment timelineFragment = new TimelineFragment();
    private Fragment groupFragment = new GroupFragment();
    private ArrayList<Fragment> mfragmentList;
    private TabFragmentPagerAdapter mAdpter;

    @Override
    public int getLayoutId() {
        return R.layout.mainactivity_in;
    }

    @Override
    public void initview() {
        main_toolbar = (Toolbar) findViewById(R.id.main_toolbar);
        main_tablayout = (TabLayout) findViewById(R.id.main_tablayout);
        main_viewpager = (ViewPager) findViewById(R.id.main_viewpager);
    }

    @Override
    public void init() {
        for (int i = 0; i < 10; i++)
        mfragmentList = new ArrayList<Fragment>();
        mfragmentList.add(timelineFragment);
        mfragmentList.add(friendFragment);
        mfragmentList.add(groupFragment);
        ArrayList<String> titles = new ArrayList<String>();
        titles.add("时间轴");
        titles.add("联系人");
        titles.add("群组");
        mAdpter = new TabFragmentPagerAdapter(getSupportFragmentManager());
        mAdpter.setData(mfragmentList);
        mAdpter.setTitles(titles);
        main_viewpager.setAdapter(mAdpter);
        main_tablayout.setupWithViewPager(main_viewpager);
    }


    @Override
    protected void processClick(View view) {

    }
}